.TH E1432_SET_AVG_MODE 3 E1432
.SH NAME
.nf
e1432_set_avg_mode \- Set averaging mode
e1432_get_avg_mode \- Get averaging mode
.fi
.IX e1432_set_avg_mode(3) 3
.IX e1432_get_avg_mode(3) 3
.SH SYNOPSIS
.cS
SHORTSIZ16 e1432_set_avg_mode(E1432ID hw, SHORTSIZ16 ID,
                              SHORTSIZ16 mode)
SHORTSIZ16 e1432_get_avg_mode(E1432ID hw, SHORTSIZ16 ID,
                              SHORTSIZ16 *mode)
.cE
.SH DESCRIPTION
\fIe1432_set_avg_mode\fR sets the data averaging mode.  At this time
averaging is only allowed on the frequency data that results from the FFT 
calculations which are turned on using \fIe1432_set_calc_data\fR 
with the \fBE1432_DATA_FREQ\fR parameter.  Averaging allows the data from multiple 
scans to be averaged together before being uploaded to the host computer.
This method both reduces noise on the data and reduces the amount of data
uploaded to the host.  The number of averages is set with the 
\fIe1432_set_avg_number\fR function.  The rate at which intermediate results 
in an average are sent to the host is controlled by \fIe1432_set_avg_update\fR.

Although averaging is performed only on frequency data, it is still
possible to read time data out of the module when averaging is taking
place.  Whenever frequency data is made available to the host (as
controlled by \fIe1432_set_avg_update\fR), time data is also made
available.  The time data is not averaged, it is just the most recent
time block (the block corresponding to the last frequency block that
was averaged into the average results).

\fIe1432_get_avg_mode\fR returns the current averaging mode.

This parameter is a "global" parameter.  It applies to an entire E1432
module rather than to one of its channels.  The \fIID\fR parameter is
used only to identify which module the function applies to, and all
channels in that module will report the same value for this parameter.

\fIhw\fR must be the result of a successful call to
\fIe1432_assign_channel_numbers\fR, and specifies the group of
hardware to talk to.

\fIID\fR is either the ID of a group of channels that was obtained with a
call to \fIe1432_create_channel_group\fR, or the ID of a single channel.

\fImode\fR selects one of the following averaging modes:

\fBE1432_AVG_NONE\fR turns off averaging.

\fBE1432_AVG_RMS\fR selects a mode where the sum of the squares of the real
and complex components of the frequency data (magnitude squared) is averaged 
point by point for the number of times specified by \fIe1432_set_avg_number\fR.  

\fBE1432_AVG_LIN\fR selects a mode where the real and complex components of 
the frequency data are averaged separately for the number of times
specified by \fIe1432_set_avg_number\fR.  

\fBE1432_AVG_EXPO\fR selects an exponential averaging mode where a weighted
sum of the squares of the real and complex components of the frequency data is 
averaged for the number of times, N, specified by \fIe1432_set_avg_number\fR.  
The weighting factor is set by the \fIe1432_set_avg_weight\fR function.  The
algorithm for this weighted average is:

.nf
result = new point              for n = 1 (first point)

result(n) = (((weight - 1.0) * result(n-1)) + new point) / weight     for n = 2 -> N
.fi

where n = point number in the average and  N = total number in the average.

\fBE1432_AVG_PEAK\fR selects a mode where the maximum values of the sum of the 
squares of the real and complex components of the frequency data is saved over
the number of times specified by \fIe1432_set_avg_number\fR.  

\fBNOTE:  the number of the averaged frequency data points for the sum of squares 
modes are one half that of the un-averaged and E1432_AVG_LIN modes, since the real 
and imaginary components are combined to form a single magnitude number.  Instead 
of BLOCKSIZE points, the magnitude squared modes will only have BLOCKSIZE/2 
points.\fR

.SH "RESET VALUE"
After a reset, \fImode\fR is set to \fBE1432_AVG_NONE\fR.
.SH "RETURN VALUE"
Return 0 if successful, a (negative) error number otherwise.
.SH "SEE ALSO"
.na
e1432_set_avg_number, e1432_set_avg_update, e1432_set_avg_weight, 
e1432_set_calc_data
.ad
